Skip to content

Use native FSEvents for file watching on macOS - #8994

Open
isaacroldan wants to merge 2 commits into
mainfrom
codex/ship-fsevents
Open

isaacroldan wants to merge 2 commits into
mainfrom
codex/ship-fsevents

Conversation

@isaacroldan

@isaacroldan isaacroldan commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Stacked on #8993.

The release bundle needs the optional fsevents module at runtime to use native file watching on macOS. Without it, Chokidar 3 defaults to polling, increasing CPU use during app dev and theme dev.

WHAT is this pull request doing?

Ship fsevents@2.3.3 as an optional runtime dependency and keep it external to the bundle. Its macOS platform restriction lets other platforms skip installation.

Apply CHOKIDAR_USEPOLLING as an explicit option before Chokidar selects the backend in app, theme, and theme-extension watchers. This preserves polling overrides when FSEvents is available and keeps the default backend when the override is unset or disabled.

Validation: 133 tests in the affected watcher test files, app/theme type checks, the CLI bundle build, and changed-file lint passed. Backend tests use the real Chokidar constructor with FSEvents available on macOS; the 12 polling-override cases failed before the fix. Native Linux and Windows checks were not run locally.

How to manually test your changes?

  1. Install a snapshot containing this PR on macOS with npm.
  2. Run shopify app dev or shopify theme dev for a local project. Create, edit, and delete a source file; confirm that changes are detected and check idle CPU use.
  3. Repeat with CHOKIDAR_USEPOLLING=true shopify app dev and CHOKIDAR_USEPOLLING=1 shopify theme dev. Confirm that file changes are detected, including in a network-mounted project where native events are unavailable.
  4. Repeat the installation in a separate directory with --omit=optional. Confirm that the CLI starts and file changes are still detected through polling.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

@isaacroldan
isaacroldan requested a review from a team as a code owner October 23, 2026 09:49
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 23, 2026
@isaacroldan

Copy link
Copy Markdown
Contributor Author

/snapit

@isaacroldan
isaacroldan added this pull request to stack #8995 October 23, 2026 09:52
@isaacroldan

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm.

Built from 0f6701b19ed467109158766d36780b159c89903e. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261023095653

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

Comment thread packages/cli/package.json
"global-agent": "3.0.0"
},
"optionalDependencies": {
"fsevents": "2.3.3"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve the polling override on macOS

Could we honor CHOKIDAR_USEPOLLING=true (and =1) when enabling FSEvents? With Chokidar 3.6.0, adding fsevents leaves useFsEvents: true despite that override, so the watcher still uses the native backend. I verified the published snapshots: 0.0.0-snapshot-20261023095012 selects polling, while 0.0.0-snapshot-20261023095653 selects FSEvents with the same override.

Users who rely on polling for network-mounted projects could miss source updates in app dev or theme dev. Please translate the override into an explicit watcher option at the app and theme watcher creation sites, and add regression coverage for the selected backend.

@isaacroldan
isaacroldan requested a review from a team as a code owner October 23, 2026 10:23
Base automatically changed from codex/app-dev-watcher-static-ignores to main October 23, 2026 10:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants